/**
 * 
 */
package com.effectivsocial.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
import org.hibernate.validator.constraints.NotEmpty;
import javax.persistence.JoinColumn;

/**
 * @author Dhrubo
 *
 */
@Entity
@Table(name = "t_network")
@Audited
public class SocialNetwork extends PersistentObject<User, String>{

	
	private static final long serialVersionUID = 1L;
	
	@Getter @Setter
	@NotEmpty
	@Column(name = "name", length = 100)
	private String name;
	
	
	
	@Getter @Setter
	@Column(name = "consumer_key", length = 250)
	private String consumerKey;
	
	
	@Getter @Setter
	@Column(name = "consumer_secret", length = 250)
	private String consumerSecret;
	
	
	@Getter @Setter
	@NotEmpty
	@Column(name = "access_token", length = 250)
	private String accessToken;
	
	
	@Getter @Setter
	@Column(name = "access_token_secret", length = 250)
	private String accessTokenSecret;
	
	
	@NotAudited
	@Getter @Setter
	@OneToOne
	private Company company;
	
	@NotAudited
	@Getter @Setter
	@OneToOne
	private NetworkType networkType;
	
	@Getter @Setter
	@Column(name = "shared_secret", length = 100, unique=true)
	private String sharedSecret;

	@NotAudited
	@Getter @Setter
    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name= "t_social_network_owners",
           joinColumns = {@JoinColumn(name="network_id")},
           inverseJoinColumns = {@JoinColumn(name="user_id")})  
	private List<User> users;   
	
}
